<?php include_once VIEWPATH.'common/dialog.php'; ?>
<script type="text/javascript">
    function on_submit(){
        var name = $("#name").val();
        var prize_data = $("#prize_data").val();
        // if(!name){ alert("名称不能为空"); return false; }
        if(!prize_data){ alert("奖励不能为空"); return false; }
        $('form').submit();
    }
    $("#edit_prize").on("hidden.bs.modal", function() {
        $(this).removeData("bs.modal");
    });
</script>

<div class="tab-pane active" id="horizontal-form">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true" aria-label="Close">×</button>
        <h5 class="modal-title"><?php echo $pageTitle;?></h5>
    </div>
    <form class="form-horizontal" name="form" id="form" action="index.php?c=<?php echo $_REQUEST['c'];?>&m=<?php echo $_REQUEST['m'];?>" name="form" method="post" enctype="multipart/form-data">
        <input type="hidden" name="id"  id="id" value="<?php echo $res['id']; ?>"/>
        <input type="hidden" name="submits" value="1"/>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">奖励名称</label>
            <div class="col-sm-4">
                <input type="text" name="label[name]" id="name" value="<?php echo $res["name"];?>" class="form-control" id="displayorder" placeholder="奖励名称">
            </div>
            <div class="col-sm-4">
                <p class="help-block">不能为空,任务列表时显示的具体奖励名。(如：+100太阳花，输入+100)</p>
            </div>
        </div>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">奖品类型</label>
            <div class="col-sm-4">
                <?php
                $groupList = $this->config->config['prize_category'];
                ?>
                <select name="label[category]" id="f_id_2" class="form-control">
                    <?php foreach($groupList as $k=>$v){ ?>
                        <option value="<?php echo $k;?>" <?php echo $res['category'] == $k ? "selected" : "";?>><?php echo $v["name"];?></option>
                    <?php } ?>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">奖励内容</label>
            <div class="col-sm-4">
                <input type="text" name="label[prize_data]" id="prize_data" value="<?php echo $res['prize_data'];?>" class="form-control" id="displayorder" placeholder="奖励内容">
            </div>
            <div class="col-sm-6">
                <p class="help-block">
                    不能为空，如果是优惠卷、红包请填写对应的id；<br>
                    如果是金币、经验请填写相应的数值;<br>
                    如果是实物商品请填写购物的url（从淘宝拷贝商品url地址到此处）img_lib/a150148732747338.png;<br>
                    如果是碎片时，请填写碎片所属的实物商品的奖励id</p>
            </div>
        </div>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">实物奖励图片</label>
            <div class="col-sm-4">
                <input type="text" name="label[img]" id="img" value="<?php echo $res['img'];?>" class="form-control" id="displayorder" placeholder="商品url：http://www.baidu.com/">
            </div>
            <div class="col-sm-6">
                <p class="help-block">可为空，只有在为实物时填写此字段，从图片库中拷贝图片地址到此处</p>
            </div>
        </div>


        <div class="modal-footer">
            <button type="reset" class="btn btn-default" data-dismiss="modal">关闭</button>
            <button type="button" onclick="on_submit()" class="btn btn-primary">保存</button>
        </div>

    </form>
</div>